<template>
  <div class="app-container">
    <el-row :gutter="20">
      <!--任务管理数据-->
      <el-col>
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true">

          <el-form-item label="时间" prop="planComplete" label-width="120px">
            <el-date-picker
              v-model="planComplete"
              clearable
              type="daterange"
              value-format="yyyy-MM-dd HH:mm:ss"
              range-separator="至"
              start-placeholder="开始日期"
              end-placeholder="结束日期">
            </el-date-picker>
          </el-form-item>
        
          <el-form-item label="监管人员名称" prop="enterpriseName" label-width="120px">
            <el-input
              v-model="queryParams.supervisor"
              placeholder="请输入监管人员名称"
              clearable
              style="width: 240px"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>

          <el-form-item>
            <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
          </el-form-item>
        </el-form>

      <el-row :gutter="10" class="mb8">
      <el-col :span="1.5">
        <el-button
          size="mini"
          type="primary"
          @click="handleTest('LEAD_INTO')"
        >导入</el-button>
        <el-button
          size="mini"
          type="primary"
          @click="handleTest('DOWNLOAD')"  
        >导入模板下载</el-button>
      </el-col>
    </el-row>

        <el-table v-loading="loading" :data="infoList">
          <el-table-column type="index" width="50" align="center" label="序号" />
          <el-table-column label="被监督单位" align="center" prop="enterpriseName" />
          <el-table-column label="检查专业" align="center" prop="checkProfessionName" />
          <el-table-column label="镇/街道" align="center" prop="town" />
          <el-table-column label="经营地址" align="center" prop="addr" />
          <el-table-column label="监督机构" align="center" prop="superviseOrg" />
          <el-table-column label="监督员" align="center" prop="supervisor" />
          <el-table-column label="计划完成时间" align="center" prop="planCompletionTime"/>
          <el-table-column label="执行状态" align="center" prop="implementStatus" >
            <template slot-scope="scope">
            <span style="margin-left: 10px">{{
              scope.row.status == "1"
                ? "执行中"
                : scope.row.status == "2"
                ? "已完成"
                : "未执行"
            }}</span>
            </template>
          </el-table-column>
          <!-- <el-table-column
            label="操作"
            align="center"
            width="160"
            class-name="small-padding fixed-width"
          >
          </el-table-column> -->
        </el-table>

        <pagination
          v-show="total>0"
          :total="total"
          :page.sync="queryParams.pageNum"
          :limit.sync="queryParams.pageSize"
          @pagination="getDoubleRandomFn"
        />
      </el-col>
    </el-row>
  
  </div>
</template>

<script>
  import { getDoubleRandom,getLeadInto,getDownloadTemplate} from "@/api/zhangping/occupational";
  export default {
    name: "User",
    data() {
      return {
          // 遮罩层
          loading: true,
          // 总条数
          total: 0,
          infoList: [],
          planComplete:'',
          // 查询参数
          queryParams: {  
              planCompletionStartTime:'', // 开始时间
              planCompletionEndTime:'',  // 结束时间
              supervisor:'',   // 监督人员
              pageNum: 1,
              pageSize: 10,
          },
          categoryList:[]
      };
    },

    created() {
        this.loading = false
        this.getDoubleRandomFn()
    },
    methods: {
        // 获取列表 
     getDoubleRandomFn(){
          if(this.planComplete !=null && this.planComplete != undefined){
              if(this.planComplete.length > 0){
                    this.queryParams.planCompletionStartTime = this.planComplete[0]
                    this.queryParams.planCompletionEndTime = this.planComplete[1]
              }    
          }else{
               this.queryParams.planCompletionStartTime = ''
               this.queryParams.planCompletionEndTime = ''
          }  
         getDoubleRandom(this.queryParams).then(res=>{
                if(res.code == 200){
                     this.infoList = res.rows
                     this.total = res.total
                }else{
                     this.$message.error(res.msg);  
                }    
         })
    },
    // 导入 

    // 表单重置
    reset() {
      this.queryParams = {
          planCompletionStartTime:'', // 开始时间
          planCompletionEndTime:'',  // 结束时间
          supervisor:'',   // 监督人员
          pageNum: 1,
          pageSize: 10,
      };
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getDoubleRandomFn()
    },
    handleTest(type){
          if(type === 'LEAD_INTO'){

          }else{

          }
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.handleQuery();
    },
    }
  };
</script>
